package utils;

import entity.Luggage;

import java.util.List;

/**
 * @author lishunlin110
 * @version 1.0
 * @description: 工具类
 * @date 2021/9/16 16:41
 */
public class Utils {
    public static List<Luggage>removeLuggage(double allowWeight,List<Luggage> list,int removeCount){
        //如果为空则直接返回这个链表
        if(list.isEmpty()){return list;}
        int count = 0;
        for(Luggage l:list){
            if(l.getWeight()<=allowWeight){
                list.remove(l);
                count++;
                if(count==removeCount) break;
            }
        }
        return list;
    }
}
